#ifndef NR_CHANNEL_INPUT_H
#define NR_CHANNEL_INPUT_H

#include "nr_data.h"
#include "nr_device.h"
#include "nr_channel_output.h"
#include "nr_device_item.h"

typedef QHash<nr_id_t, nr_channel_output*> nr_output_channels;

class nr_channel_input : 
    public nr_object, 
    public nr_channel_operation, 
    public nr_device_delegate,
    public nr_channel_operation_delegate
{
public:
    nr_channel_input();
    ~nr_channel_input();
    
    nr_error_t put_data(nr_data* data);
    nr_error_t put_event(nr_event* evt);
    
    void attach_device_item(nr_device_item *item);

    nr_error_t add_output_channel(nr_channel_output *output_channel);
    nr_error_t remove_output_channel(nr_channel_output *output_channel);
    
    nr_output_channels& channels() { return m_output_channels; }
    
    bool is_empty() { return m_output_channels.empty(); }

    virtual nr_error_t start();
    virtual nr_error_t pause();
    virtual nr_error_t stop();
    
    virtual void on_data_received(nr_data *data);
    virtual void on_event_report(nr_event *evt);

    virtual nr_error_t on_starting(nr_channel_operation& operation);
    virtual nr_error_t on_started(nr_channel_operation& operation);
    
    virtual nr_error_t on_pausing(nr_channel_operation& operation);
    virtual nr_error_t on_paused(nr_channel_operation& operation);

    virtual nr_error_t on_stopping(nr_channel_operation& operation);
    virtual nr_error_t on_stopped(nr_channel_operation& operation);

private:
    nr_output_channels m_output_channels;
    nr_device_item *m_device_item;
};

#endif // NR_CHANNEL_INPUT_H
